<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="generator" content="PHPDoctor 2RC4 (http://peej.github.com/phpdoctor/)">
<meta name="when" content="Fri, 23 Jul 2010 20:16:22 +0000">

<link rel="stylesheet" type="text/css" href="../stylesheet.css">
<link rel="start" href="../overview-summary.html">

<title>HR_api.class.php (Hosting Reborn API PHP Library)</title>

</head>
<body id="file" onload="parent.document.title=document.title;">

<div class="header">
<h1>Hosting Reborn API PHP Library</h1>
<ul>
<li><a href="../overview-summary.html">Overview</a></li>
<li>Package</li><li>Class</li><li>Tree</li><li><a href="../overview-files.html">Files</a></li>
<li><a href="../deprecated-list.html">Deprecated</a></li>
<li><a href="../index-all.html">Index</a></li>
</ul>
</div>

<div class="small_links">
<a href="../index.html" target="_top">Frames</a>
<a href="../source/hr_api.class.php.html" target="_top">No frames</a>
</div>
<hr>

<h1>HR_api.class.php</h1>
<hr>

<a name="line1"></a><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<a name="line2"></a><span style="color: #009933; font-style: italic;">/** ABSTRACT core interface to the Hosting Reborn API functions.
<a name="line3"></a> *
<a name="line4"></a> * &lt;p&gt;For interfaces to API methods see:&lt;/p&gt;
<a name="line5"></a> * &lt;ul&gt;
<a name="line6"></a> *   &lt;li&gt;&lt;a href=&quot;HR_accountapi.html&quot;&gt;HR_accountApi&lt;/a&gt;&lt;/ll&gt;
<a name="line7"></a> *   &lt;li&gt;&lt;a href=&quot;HR_hostingaccountapi.html&quot;&gt;HR_hostingaccountApi&lt;/a&gt;&lt;/ll&gt;
<a name="line8"></a> *   &lt;li&gt;&lt;a href=&quot;HR_notificationapi.html&quot;&gt;HR_notificationApi&lt;/a&gt;&lt;/ll&gt;
<a name="line9"></a> *   &lt;li&gt;&lt;a href=&quot;HR_priceapi.html&quot;&gt;HR_priceApi&lt;/a&gt;&lt;/ll&gt;
<a name="line10"></a> *   &lt;li&gt;&lt;a href=&quot;HR_serverapi.html&quot;&gt;HR_serverApi&lt;/a&gt;&lt;/ll&gt;
<a name="line11"></a> *   &lt;li&gt;&lt;a href=&quot;HR_transactionapi.html&quot;&gt;HR_transactionApi&lt;/a&gt;&lt;/ll&gt;
<a name="line12"></a> * &lt;/ul&gt;
<a name="line13"></a> *
<a name="line14"></a> * @package com\hostingreborn\api
<a name="line15"></a> * @link https//api.hostingreborn.com/docs/functions/
<a name="line16"></a> * @abstract
<a name="line17"></a> *
<a name="line18"></a> *
<a name="line19"></a> * @author      Jon Cram &lt;jon@hostingreborn.com&gt;
<a name="line20"></a> * @copyright   https://api.hostingreborn.com/code/copyright/
<a name="line21"></a> * @license     https://api.hostingreborn.com/code/license/
<a name="line22"></a> * @version     1.0
<a name="line23"></a> *
<a name="line24"></a> * $Date: 2010/07/04 22:51:02 $
<a name="line25"></a> * $Revision: 2c423d307a13 $
<a name="line26"></a> * 
<a name="line27"></a> */</span>
<a name="line28"></a>&nbsp;
<a name="line29"></a><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HR_apiExceptions.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line30"></a><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HR_apiRequestUrl.class.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line31"></a><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HR_apiResponse.class.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line32"></a>&nbsp;
<a name="line33"></a>abstract <span style="color: #000000; font-weight: bold;">class</span> HR_api <span style="color: #009900;">&#123;</span>
<a name="line34"></a>&nbsp;
<a name="line35"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line36"></a>    <span style="color: #666666; font-style: italic;">/* Attributes                                                              */</span>
<a name="line37"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line38"></a>&nbsp;
<a name="line39"></a>    <span style="color: #000000; font-weight: bold;">private</span> static <span style="color: #000088;">$requestUrl</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<a name="line40"></a>&nbsp;
<a name="line41"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$apiDomain</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<a name="line42"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$apiDomainIsSecure</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<a name="line43"></a>&nbsp;
<a name="line44"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line45"></a>    <span style="color: #666666; font-style: italic;">/* Constructors                                                            */</span>
<a name="line46"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line47"></a>&nbsp;
<a name="line48"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line49"></a>     *
<a name="line50"></a>     * @param string $apiDomain Optional, the API domain name.
<a name="line51"></a>     * @param bool $apiDomainIsSecure Optional, whether the API offers secure connections
<a name="line52"></a>     */</span>
<a name="line53"></a>    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$apiDomain</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$apiDomainIsSecure</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line54"></a>&nbsp;
<a name="line55"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_null"><span style="color: #990000;">is_null</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$apiDomain</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line56"></a>            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setApiDomain</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$apiDomain</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line57"></a>        <span style="color: #009900;">&#125;</span>
<a name="line58"></a>&nbsp;
<a name="line59"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_null"><span style="color: #990000;">is_null</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$apiDomainIsSecure</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line60"></a>            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setApiDomainIsSecure</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$apiDomainIsSecure</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line61"></a>        <span style="color: #009900;">&#125;</span>
<a name="line62"></a>    <span style="color: #009900;">&#125;</span>
<a name="line63"></a>&nbsp;
<a name="line64"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line65"></a>    <span style="color: #666666; font-style: italic;">/* Public methods                                                          */</span>
<a name="line66"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line67"></a>&nbsp;
<a name="line68"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line69"></a>     * Read data from the API (a GET request)
<a name="line70"></a>     *
<a name="line71"></a>     * @param string $request The URL to read from.
<a name="line72"></a>     * @return HR_apiResponse
<a name="line73"></a>     */</span>
<a name="line74"></a>    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> read<span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line75"></a>        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line76"></a>    <span style="color: #009900;">&#125;</span>
<a name="line77"></a>&nbsp;
<a name="line78"></a>&nbsp;
<a name="line79"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line80"></a>     * Write data to the API (a POST request)
<a name="line81"></a>     *
<a name="line82"></a>     * @param string $request The URL to write to
<a name="line83"></a>     * @param array $arguments An array of key:value POST arguments
<a name="line84"></a>     * @return HR_apiResponse
<a name="line85"></a>     */</span>
<a name="line86"></a>    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> write<span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$arguments</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line87"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line88"></a>            <span style="color: #000088;">$arguments</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line89"></a>        <span style="color: #009900;">&#125;</span>
<a name="line90"></a>&nbsp;
<a name="line91"></a>        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">,</span> <span style="color: #000088;">$arguments</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line92"></a>    <span style="color: #009900;">&#125;</span>
<a name="line93"></a>&nbsp;
<a name="line94"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line95"></a>    <span style="color: #666666; font-style: italic;">/* Private methods                                                         */</span>
<a name="line96"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line97"></a>&nbsp;
<a name="line98"></a>&nbsp;
<a name="line99"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line100"></a>     *  Optionally specify the API request domain name.
<a name="line101"></a>     *
<a name="line102"></a>     * @param string $domain The domain name for the API request URL
<a name="line103"></a>     * @return bool
<a name="line104"></a>     */</span>
<a name="line105"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setApiDomain<span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line106"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_string"><span style="color: #990000;">is_string</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line107"></a>            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">apiDomain</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<a name="line108"></a>            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<a name="line109"></a>        <span style="color: #009900;">&#125;</span>
<a name="line110"></a>&nbsp;
<a name="line111"></a>        <span style="color: #000088;">$domain</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line112"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line113"></a>            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">apiDomain</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<a name="line114"></a>            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<a name="line115"></a>        <span style="color: #009900;">&#125;</span>
<a name="line116"></a>&nbsp;
<a name="line117"></a>        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">apiDomain</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$domain</span><span style="color: #339933;">;</span>
<a name="line118"></a>    <span style="color: #009900;">&#125;</span>
<a name="line119"></a>&nbsp;
<a name="line120"></a>&nbsp;
<a name="line121"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line122"></a>     * Optionally specify whether to make secure (HTTPS) requests to the API domain.
<a name="line123"></a>     *
<a name="line124"></a>     * @param bool $isSecure
<a name="line125"></a>     * @return bool
<a name="line126"></a>     */</span>
<a name="line127"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setApiDomainIsSecure<span style="color: #009900;">&#40;</span><span style="color: #000088;">$isSecure</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line128"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_bool"><span style="color: #990000;">is_bool</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$isSecure</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line129"></a>            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">apiDomainIsSecure</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<a name="line130"></a>            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<a name="line131"></a>        <span style="color: #009900;">&#125;</span>
<a name="line132"></a>&nbsp;
<a name="line133"></a>        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">apiDomainIsSecure</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$isSecure</span><span style="color: #339933;">;</span>
<a name="line134"></a>    <span style="color: #009900;">&#125;</span>
<a name="line135"></a>&nbsp;
<a name="line136"></a>&nbsp;
<a name="line137"></a>    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> buildArguments<span style="color: #009900;">&#40;</span><span style="color: #000088;">$standardArguments</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fullArgumentList</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$additionalArguments</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line138"></a>        <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array_merge"><span style="color: #990000;">array_merge</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$standardArguments</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAdditionalArguments</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtraFullArguments</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$standardArguments</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fullArgumentList</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line139"></a>    <span style="color: #009900;">&#125;</span>
<a name="line140"></a>&nbsp;
<a name="line141"></a>&nbsp;
<a name="line142"></a>    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> buildQueryString<span style="color: #009900;">&#40;</span><span style="color: #000088;">$standardArguments</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fullArgumentList</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$additionalArguments</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line143"></a>        <span style="color: #b1b100;">return</span> <a href="http://www.php.net/http_build_query"><span style="color: #990000;">http_build_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">buildArguments</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$standardArguments</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fullArgumentList</span><span style="color: #339933;">,</span> <span style="color: #000088;">$additionalArguments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line144"></a>    <span style="color: #009900;">&#125;</span>
<a name="line145"></a>&nbsp;
<a name="line146"></a>&nbsp;
<a name="line147"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getAdditionalArguments<span style="color: #009900;">&#40;</span><span style="color: #000088;">$additionalArguments</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line148"></a>        <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$additionalArguments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$additionalArguments</span> <span style="color: #339933;">:</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line149"></a>    <span style="color: #009900;">&#125;</span>
<a name="line150"></a>&nbsp;
<a name="line151"></a>&nbsp;
<a name="line152"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getExtraFullArguments<span style="color: #009900;">&#40;</span><span style="color: #000088;">$standardArguments</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fullArgumentList</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
<a name="line153"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$standardArguments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line154"></a>            <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line155"></a>        <span style="color: #009900;">&#125;</span>
<a name="line156"></a>&nbsp;
<a name="line157"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fullArgumentList</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line158"></a>            <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line159"></a>        <span style="color: #009900;">&#125;</span>
<a name="line160"></a>&nbsp;
<a name="line161"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fullArgumentList</span><span style="color: #009900;">&#91;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$standardArguments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line162"></a>            <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line163"></a>        <span style="color: #009900;">&#125;</span>
<a name="line164"></a>&nbsp;
<a name="line165"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fullArgumentList</span><span style="color: #009900;">&#91;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$standardArguments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line166"></a>            <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line167"></a>        <span style="color: #009900;">&#125;</span>
<a name="line168"></a>&nbsp;
<a name="line169"></a>        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$fullArgumentList</span><span style="color: #009900;">&#91;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$standardArguments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<a name="line170"></a>    <span style="color: #009900;">&#125;</span>
<a name="line171"></a>&nbsp;
<a name="line172"></a>&nbsp;
<a name="line173"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line174"></a>     * Query the API
<a name="line175"></a>     *
<a name="line176"></a>     * @param string $request
<a name="line177"></a>     * @param array $arguments
<a name="line178"></a>     * @return boolean
<a name="line179"></a>     */</span>
<a name="line180"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$arguments</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line181"></a>        <span style="color: #666666; font-style: italic;">// Proceed no further if we have nothing to do</span>
<a name="line182"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_string"><span style="color: #990000;">is_string</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line183"></a>            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<a name="line184"></a>        <span style="color: #009900;">&#125;</span>
<a name="line185"></a>&nbsp;
<a name="line186"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_null"><span style="color: #990000;">is_null</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line187"></a>            <span style="color: #000088;">$arguments</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line188"></a>        <span style="color: #009900;">&#125;</span>
<a name="line189"></a>&nbsp;
<a name="line190"></a>        <span style="color: #666666; font-style: italic;">// Issue request and get server response</span>
<a name="line191"></a>        <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">requestUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$request</span><span style="color: #339933;">;</span>
<a name="line192"></a>        <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStreamOptions</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line193"></a>        <span style="color: #000088;">$context</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/stream_context_create"><span style="color: #990000;">stream_context_create</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line194"></a>&nbsp;
<a name="line195"></a>        <span style="color: #000088;">$serverResponse</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$context</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line196"></a>&nbsp;
<a name="line197"></a>        <span style="color: #666666; font-style: italic;">// Prepare response</span>
<a name="line198"></a>        <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> HR_apiResponse<span style="color: #009900;">&#40;</span><span style="color: #000088;">$serverResponse</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line199"></a>    <span style="color: #009900;">&#125;</span>
<a name="line200"></a>&nbsp;
<a name="line201"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line202"></a>     * Factory method for getting the main API request URL object
<a name="line203"></a>     *
<a name="line204"></a>     * @return string
<a name="line205"></a>     */</span>
<a name="line206"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> requestUrl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line207"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_null"><span style="color: #990000;">is_null</span></a><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$requestUrl</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line208"></a>            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$requestUrl</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HR_apiRequestUrl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">apiDomain</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">apiDomainIsSecure</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line209"></a>        <span style="color: #009900;">&#125;</span>
<a name="line210"></a>&nbsp;
<a name="line211"></a>        <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$requestUrl</span><span style="color: #339933;">;</span>
<a name="line212"></a>    <span style="color: #009900;">&#125;</span>
<a name="line213"></a>&nbsp;
<a name="line214"></a>&nbsp;
<a name="line215"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line216"></a>     * Make and get the HTTP request stream options
<a name="line217"></a>     *
<a name="line218"></a>     * @return array
<a name="line219"></a>     */</span>
<a name="line220"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getStreamOptions<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line221"></a>        <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line222"></a>&nbsp;
<a name="line223"></a>        <span style="color: #666666; font-style: italic;">// HTTP options</span>
<a name="line224"></a>        <span style="color: #666666; font-style: italic;">// -&gt; request method, headers and payload</span>
<a name="line225"></a>        <span style="color: #000088;">$body</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequestBody</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line226"></a>&nbsp;
<a name="line227"></a>        <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'http'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
<a name="line228"></a>                <span style="color: #0000ff;">'method'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">determineRequestMethod</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<a name="line229"></a>                <span style="color: #0000ff;">'header'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Content-type: application/x-www-form-urlencoded<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span>
<a name="line230"></a>                        <span style="color: #0000ff;">&quot;Content-length: &quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span>
<a name="line231"></a>                        <span style="color: #0000ff;">&quot;Connection: close&quot;</span><span style="color: #339933;">,</span>
<a name="line232"></a>                <span style="color: #0000ff;">'content'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$body</span>
<a name="line233"></a>        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line234"></a>&nbsp;
<a name="line235"></a>        <span style="color: #666666; font-style: italic;">// HTTPS options (if relevant)</span>
<a name="line236"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">requestUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isSecure</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line237"></a>            <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'https'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
<a name="line238"></a>                    <span style="color: #0000ff;">'allow_self_signed'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'true'</span><span style="color: #339933;">,</span>
<a name="line239"></a>                    <span style="color: #0000ff;">'verify_peer'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'false'</span>
<a name="line240"></a>            <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line241"></a>        <span style="color: #009900;">&#125;</span>
<a name="line242"></a>&nbsp;
<a name="line243"></a>        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$options</span><span style="color: #339933;">;</span>
<a name="line244"></a>    <span style="color: #009900;">&#125;</span>
<a name="line245"></a>&nbsp;
<a name="line246"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line247"></a>     * Get outbound request body, made from the request arguments
<a name="line248"></a>     *
<a name="line249"></a>     * @param array $arguments
<a name="line250"></a>     * @return string
<a name="line251"></a>     *
<a name="line252"></a>     */</span>
<a name="line253"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getRequestBody<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line254"></a>        <span style="color: #b1b100;">return</span> <a href="http://www.php.net/http_build_query"><span style="color: #990000;">http_build_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line255"></a>    <span style="color: #009900;">&#125;</span>
<a name="line256"></a>&nbsp;
<a name="line257"></a>&nbsp;
<a name="line258"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line259"></a>     * Determine request type (GET or POST) from request arguments array
<a name="line260"></a>     *
<a name="line261"></a>     * @param array $arguments
<a name="line262"></a>     * @return string
<a name="line263"></a>     *
<a name="line264"></a>     */</span>
<a name="line265"></a>    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> determineRequestMethod<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line266"></a>        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line267"></a>            <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'GET'</span><span style="color: #339933;">;</span>
<a name="line268"></a>        <span style="color: #009900;">&#125;</span>
<a name="line269"></a>&nbsp;
<a name="line270"></a>        <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arguments</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'GET'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'POST'</span><span style="color: #339933;">;</span>
<a name="line271"></a>    <span style="color: #009900;">&#125;</span>
<a name="line272"></a>&nbsp;
<a name="line273"></a><span style="color: #009900;">&#125;</span>
<a name="line274"></a>&nbsp;
<a name="line275"></a><span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
<div class="header">
<h1>Hosting Reborn API PHP Library</h1>
<ul>
<li><a href="../overview-summary.html">Overview</a></li>
<li>Package</li><li>Class</li><li>Tree</li><li><a href="../overview-files.html">Files</a></li>
<li><a href="../deprecated-list.html">Deprecated</a></li>
<li><a href="../index-all.html">Index</a></li>
</ul>
</div>

<div class="small_links">
<a href="../index.html" target="_top">Frames</a>
<a href="../source/hr_api.class.php.html" target="_top">No frames</a>
</div>
<hr>

<p id="footer">This document was generated by <a href="http://peej.github.com/phpdoctor/">PHPDoctor: The PHP Documentation Creator</a></p>

</body>

</html>